package com.nl.controller.xuyi.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.nl.controller.common.model.Response;
import com.nl.controller.common.util.ResponseUtil;
import com.nl.controller.web.bean.XuYiStation;
import com.nl.controller.xuyi.service.XuYiPathService;

import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@RequestMapping("/xuYiPath")
@RestController
public class XuYiPathController {
	@Autowired
	XuYiPathService xuYiPathService;
	
    @PostMapping("findXuYiPathList")
    public Response<String> findXuYiPathList(
    		@RequestParam(value = "page", required = true) int page,
            @RequestParam(value = "limit", required = true) int limit,
    		@RequestParam(value = "pathName", required = false) String pathName
    		) {
        	PageInfo<XuYiStation> pageInfo  = xuYiPathService.findXuYiPathList(page,limit,pathName);
        return ResponseUtil.sucess(pageInfo.getList(), pageInfo.getTotal());
    }
    
    
    @ApiOperation(value = "删除路线信息", notes = "删除路线信息")
	@PostMapping("deletePath")
	private Response deletePath(
			@RequestParam(value = "pathName") String pathName,
			@RequestParam Map<String, Object> paramMap) {
		int result = xuYiPathService.deletePath(pathName);
		if(result>0){
			log.info("删除路线信息:{}" ,paramMap.toString());
			log.info("删除路线信息：",result);
			return ResponseUtil.sucess("success");
		} else {
			log.error("删除路线信息：{}", result);
			return ResponseUtil.error(-1, "删除路线信息失败，请重试");
		}

	}
    
}
